import indexView from '@/views/index'
import homeView from '@/views/home'
// import $ from 'jquery'
// import { get } from '@/utils/http'
// import apiConfig from '@/config/api'
import { getUserList } from '@/model/userModel'

class HomeController {
  index(router) {
    return async (req, res) => {
      /* let data = await $.get('/api/users')
    console.log(data) */
      // let data = await get(apiConfig.users)
      let data = await getUserList()
      if (!data) router.go('/login')
      else {
        res.render(indexView({ data }))
      }
    }
  }

  home(req, res) {

    res.render(homeView())
    // 事件，js业务处理
    /* $('#btn').click(function () {
      console.log('我是一个按钮')
    }) */
  }

  detail(req, res) {
    console.log(req.params)
  }
}

export default new HomeController()